<div class="block">
	<div class="block-title"><?php echo $block_title ?></div>
	<div class="block-body">
		<form method="get" action="<?=$this->createUrl('owner/report/firstOrder')?>">
			<table>
				<tr>
					<td width="80">Report For:</td>
					<td> 
						<select name="website_id">	
							<option value=""> - All Qpid Dating Sites - </option>
							<?php foreach (Website::model()->findAll() as $k => $website): ?>
							<option value="<?php echo $website['website_id']?>" <?php if ($website_id==$website['website_id']) echo 'selected="selected"'?>>
								<?php echo str_ireplace('www.', '', $website['domain'])?>
							</option>
							<?php endforeach ?>
						</select>
					</td>
				</tr>
				<tr>
					<td>Date Range: </td>
					<td>
						<select name="year_start">
							<?php foreach (array(date('Y'), date('Y')-1) as $year): ?>
							<option value="<?php echo $year ?>" <?php if ($year==$year_start) echo 'selected="selected"'?>>
								<?php echo $year ?>
							</option>
							<?php endforeach ?>
						</select>
						<select name="month_start">
							<?php foreach (range(1, 12) as $month): ?>
							<option value="<?php echo $month?>" <?php if ($month==$month_start) echo 'selected="selected"'?>>
								<?php echo $month?>
							</option>
							<?php endforeach ?>
						</select>
						<select name="day_start">
							<?php foreach (range(1, 31) as $day): ?>
							<option value="<?php echo $day?>" <?php if ($day==$day_start) echo 'selected="selected"'?>>
								<?php echo $day?>
							</option>
							<?php endforeach ?>
						</select>
						&nbsp;&nbsp;
						To:
						&nbsp;&nbsp; 
						<select name="year_end">
							<?php foreach (array(date('Y'), date('Y')-1) as $year): ?>
							<option value="<?php echo $year ?>" <?php if ($year==$year_end) echo 'selected="selected"'?>>
								<?php echo $year ?>
							</option>
							<?php endforeach ?>
						</select>
						<select name="month_end">
							<?php foreach (range(1, 12) as $month): ?>
							<option value="<?php echo $month?>" <?php if ($month==$month_end) echo 'selected="selected"'?>>
								<?php echo $month?>
							</option>
							<?php endforeach ?>
						</select>
						<select name="day_end">
							<?php foreach (range(1, 31) as $day): ?>
							<option value="<?php echo $day?>" <?php if ($day==$day_end) echo 'selected="selected"'?>>
								<?php echo $day?>
							</option>
							<?php endforeach ?>
						</select>
					</td>
				</tr>
				<tr>
					<td>Report Style</td>
					<td>
						<label><input type="radio" name="style" value="detail" <?php if ($style=='detail') echo 'checked="checked"'?> />Detail </label>&nbsp;&nbsp;&nbsp;
						<label><input type="radio" name="style" value="summary" <?php if ($style=='summary') echo 'checked="checked"'?> />Summary</label>
					</td>
				</tr>
				<tr>
					<td></td>
					<td><input type="submit" value="Generate" /></td>
				</tr>
			</table>
		</form>
		
		<?php 
		if ($style=='detail') {
			 $this->widget('zii.widgets.grid.CGridView', array(
				'id'=>'report-grid',
			 	'summaryText' => '',
				'dataProvider'=>$dataProvider,
				'columns'=>array(
					array('name' => 'Website', 'value' => '$data->website'),
					array('name' => 'Date', 'value' => '$data->adddate'),
					array('name' => 'Member ID', 'value' => '$data->user_id'),
					array('name' => 'Amount', 'value' => '"\$".$data->amount')
				),
			));
		} else {
			$this->widget('zii.widgets.grid.CGridView', array(
				'id'=>'report-grid',
				'summaryText' => '',
				'dataProvider'=>$dataProvider,
				'columns'=>array(
					'Website',
					'Clicks',
					'Members',
					'Orders'
				),
			));
		}
		?>
		
	</div>
</div>